{include file="public/layout" /}
<div class="ncap-form-default">
    <form id="admin_form" method="post" action="" name="admin_form" data-action="{:url('admin/Admin/modifyPwd', ['id'=>$info['id']])}">
        <dl class="row">
            <dt class="tit"><label for="old_pwd"><em>*</em>原密码</label><!-- 原密码 --></dt>
            <dd class="opt"><input id="old_pwd" name="old_pwd" class="txt valid" type="password">
                <span class="err"></span></dd>
        </dl>
        <dl class="row">
            <dt class="tit"><label for="new_pwd"><em>*</em>新密码</label><!-- 新密码 --></dt>
            <dd class="opt"><input id="new_pwd" name="new_pwd" class="txt" type="password">
                <span class="err"></span></dd>
        </dl>
        <dl class="row">
            <dt class="tit"><label for="new_pwd2"><em>*</em>确认密码</label><!-- 确认密码--></dt>
            <dd class="opt"><input id="new_pwd2" name="new_pwd2" class="txt" type="password">
                <span class="err"></span></dd>
        </dl>
        <div class="bot"><a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn"><span>确认提交</span></a></div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $('#submitBtn').click(function(){
            $('#admin_form').submit();
        });
        $("#admin_form").validate({
            debug: false, //调试模式取消submit的默认提交功能
            focusInvalid: false, //当为false时，验证无效时，没有焦点响应
            onkeyup: false,
            submitHandler: function(form){   //表单提交句柄,为一回调函数，带一个参数：form
                $.ajax({
                    url:$('#admin_form').data('action'),
                    type:'post',
                    dataType:'json',
                    data: $("#admin_form").serialize(),
                    success:function(obj){
                        if(obj.status !=1){
                            layer.alert(obj.msg, {icon: 3});
                        }else{
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.msg('密码修改成功', {icon:1, time:1000});
                            setTimeout(function(){
                                parent.layer.close(index);
                            },1200);
                        }
                    }
                });
            },
            ignore:":button",	//不验证的元素
            rules:{
                old_pwd:{
                    required:true,
                    minlength:6
                },
                new_pwd:{
                    required:true,
                    minlength:6
                },
                new_pwd2:{
                    required:true,
                    minlength:6,
                    equalTo: "#new_pwd"
                }
            },
            messages:{
                old_pwd:{
                    required:"请输入原始密码",
                    minlength:"原始密码长度不能少于6位"
                },
                new_pwd:{
                    required:"请输入新密码",
                    minlength:"新密码长度不能少于6位"
                },
                new_pwd2:{
                    required:"请输入确认密码",
                    minlength:"确认密码长度不能少于6位",
                    equalTo:"两次密码输入不一致"
                }
            }
        });

    });

</script>